count occurrences of a character